<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>{$row.name}</title>
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/zhaomu.css"/>
    <link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/questionnaire.css"/>
    <link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/questionnaire1.css"/>
    <script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/layer_mobile/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/layer.css" />
    <script src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/jquery.1.9.1.js"></script>
    <script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/rem.js"></script>
    <script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/address_select/mobileSelect.js"></script>
    <link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/address_select/mobileSelect.css" />
    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
</head>
<body class="body_tj">
<script>
    wx.config({$jssdk});
    // wx.ready(function(){
    //   wx.hideMenuItems({
    //     menuList: ['menuItem:share:appMessage',"menuItem:share:timeline"]
    //   });
    // });
    wx.ready(function(){
        wx.hideOptionMenu()
    });
</script>
{if $dati == 0}
{if $row->is_source == 1}
<script>

    //非法来源注释
    var fromurl = document.referrer;
    fromurl = fromurl.toLowerCase();
    var aSites = new Array('xiaoeknow.com');
    var b = false;
    for (i in aSites){
        console.log(fromurl.indexOf(aSites[i]));
        if (fromurl.indexOf(aSites[i]) < 0 ){
            b = true;
            break;
        }
    }
    if(b){
        layer.open({
            content: '请在直播间点击链接领取',//您未认真听讲或未认真答题，请重新答题
            skin: 'msg',
            time: 2,
        });
        setTimeout(function(){
            window.location.href = 'https://shoptest.fc62.com/';
        }, 1000);

    }
    console.log("来源  "+fromurl);
</script>
{/if}
<div id="wenjuanqqwe">
    <img style="width: 100%;" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/question_top5.jpg"/>
    <ul class="question">
        {foreach name="$info" item="vo"}
        <li>
            <p>{$key+1}. {$vo->name} {if $vo->must_fil == 1}<span style="color: #ff0000;">*</span>{/if}</p>
            <input type="hidden" id="wenjuan{$key}" value="{$vo->must_fil}" />
            <input type="hidden" id="wenjuantype{$key}" value="{$vo->type}" />
            {if $vo.type == 1}
            {foreach name="$vo->Datas" key="k" item="v" }
            <p>
                <input  type="radio"  class="question-radio" name="wenjuan{$key}" id="a{$key}{$k}" value="{$vo->id}-{$v->name}-{$v->answer}" />

                <label class="radio-label question-label" for="a{$key}{$k}"><span>{$v->name}.{$v->answer}</span></label>
            </p>
            {/foreach}
            {elseif $vo.type == 2}
            {foreach name="$vo->Datas" key="k" item="v" }
            <p>
                <input type="checkbox" name="wenjuan{$key}" id="a{$key}{$k}" value="{$vo->id}-{$v->name}-{$v->answer}" />
                <label class="checkbox-label" for="a{$key}{$k}"><span>{$v->name}.{$v->answer}</span></label>
            </p>
            {/foreach}
            {/if}
        </li>
        {/foreach}

    </ul>
    <div class="question_mid">
        <p class="mid_top">感谢您的答题！祝孩子考出最好的自己，高考成功！</p>
        <div>
            <p class="mid_mid">
            <p class="ktkj ylfx">提交问卷后，查看《高考一轮复习方向作业》电子版样张并领取纸质版</p>
            <span class="question_submit">点击领取</span>
            </p>
        </div>
        <!--<p class="mid_bottom">* 语文为不公开领取，只公布电子版样张供家长参考</p>-->
    </div>
    <!-- <div class="question_mid">
        <img class="mid_img" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/mid_top.jpg"/>
        <img class="mid_img question_submit" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/mid_mid.jpg"/>
        <p class="mid_bottom">* 语文为不公开领取，只公布电子版样张供家长参考</p>
    </div> -->

</div>
<script>
    var count = {:count($info)};
    var jsonData={};
    $(function(){
        $('.question_submit').click(function(){
            for (var i = 0; i < count; i++) {
                var type= $("#wenjuantype"+i).val();
                console.log(type);
                if(type == 1){
                    var wenjuan = $("input[name='wenjuan"+i+"']:checked").val();
                }else if(type == 2){
                    var wenjuan = "";
                    $("input[name='wenjuan"+i+"']:checked").each(function(){
                        wenjuan += $(this).val() + "||";
                    });
                    if(wenjuan.length > 0){
                        wenjuan = wenjuan.substring(0, wenjuan.length - 2); //把最后一个逗号去掉
                    }
                    console.log(wenjuan);
                }
                var must_fil= $("#wenjuan"+i).val();

                if(must_fil == 1){
                    if(wenjuan == ""||wenjuan == null){
                        layer.open({
                            content: '请填写听课效果问卷后点击领取',
                            skin: 'msg',
                            time: 2 //2秒后自动关闭
                        });
                        return false;
                    }
                }
                jsonData['wenjuan'+i] = wenjuan;
            }
            console.log(jsonData);
            $.ajax({
                type: 'post',
                url:"/index/ques/volumepost/ids/{$row->id}" ,
                data:jsonData,
                success: function(data){
                    console.log(data);
                    if (data.code == 0) {
                        layer.open({
                            content: data.msg,//您未认真听讲或未认真答题，请重新答题
                            skin: 'msg',
                            time: 2,
                        });
                        return false;
                    } else {
                        // layer.open({
                        //   content: data.msg,//您未认真听讲或未认真答题，请重新答题
                        //   skin: 'msg',
                        //   time: 2,
                        // });
                        // setTimeout(function(){
                        //     window.location.reload();
                        // }, 2000);
                        window.scroll(0, 0);
                        window.location.reload();

                    }
                }
            });
        });
    });
</script>
<!--问卷结束-->
{else}

{if !$edit}
<!-- add表单开始   -->
<div class="addressmone" style="display: block;">

    <div class="question_mid">
        <a href="http://uploadfile.fc62.com/ques/%E6%96%B9%E5%90%91%E4%BD%9C%E4%B8%9A%E5%8D%B7-%E5%85%A8%E5%9B%BD%E7%94%B5%E5%AD%90%E7%89%88.pdf"><img class="mid_img" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/question_mid3.jpg"/></a>
    </div>
    <ul>
        <li>
            <p style="font-size: 0.3rem;color: #666;">纸质版领取,请填写寄送地址</p>
            <p style="color: #ff0000;font-size: 0.26rem;">* 免收快递费</p>
        </li>
        <li>
            <p class="form_con">学生姓名 <span style="color: #ff0000;">*</span></p>
            <input type="text" name="consignee" value="" id="name" >
            <img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_1.jpg"/>
        </li>
        <li>
            <p class="form_con">家长姓名 <span style="color: #ff0000;">*</span></p>
            <p class="tips">用于领书确认联络</p>
            <input type="text" name="parent_name" value="" id="parent_name" >
            <img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_1.jpg"/>
        </li>
        <li style="position: relative;">
            <p class="form_con">所在学校 <span style="color: #ff0000;">*</span></p>
            <div id="trigger5" class="trigger4" style="text-indent:0.5em;display: inline-block;border: 1px solid #ccc;width: 100%;height: 35px;line-height: 35px;border-radius: 5px;overflow: hidden;">
                <span style="color: #666;">请选择</span>
            </div>
            <img style="position: absolute;bottom: 0.3rem;left: 92%;width: 0.26rem;height: 0.13rem;" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/tj.png"/>
            <input type="hidden" name="" id="school" value="" />
            <input type="hidden" name="" id="classname" value="" />
        </li>

        <div class="hide" style="position: relative;">
            <img class="selectjt" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/tj.png" alt="">
            <select class="selectchoose" name="totalschool" id="totalschool" value="">
                <option value ="0">请选择学校</option>
                {foreach name="$base_school" item="vobasc"}
                <option value ="{$vobasc->id}">{$vobasc->name}</option>
                {/foreach}
            </select>
        </div>
        <li class="hide">
            <p class="form_con">班级 <span style="color: #ff0000;">*</span></p>
            <input type="text" name="qitaclassname" value="" id="qitaclassname" >
            <img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_4.jpg"/>
        </li>
        <li style="position: relative;">
            <p class="form_con">所在地区 <span style="color: #ff0000;">*</span></p>
            <div id="trigger4" class="trigger4" style="text-indent:0.5em;display: inline-block;border: 1px solid #ccc;width: 100%;height: 35px;line-height: 35px;border-radius: 5px;overflow: hidden;">
                <span style="color: #666;">{$area.address_text??'请选择'}</span>
            </div>
            <img style="position: absolute;bottom: 0.3rem;left: 92%;width: 0.26rem;height: 0.13rem;" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/tj.png"/>
            <input type="hidden" name="" id="sheng" value="{$area.province??''}" />
            <input type="hidden" name="" id="shi" value="{$area.city??''}" />
            <input type="hidden" name="" id="xian" value="{$area.area??''}" />
        </li>

        <li>
            <p class="form_con">详细地址 <span style="color: #ff0000;">*</span></p>
            <textarea name="address" id="address" placeholder="用户寄达赠书使用，请认真填写"></textarea>
        </li>
        <li>
            <p class="form_con">联系电话 <span style="color: #ff0000;">*</span></p>
            <input type="number" pattern="[0-9]*" name="" id="tel" value="" />
            <img style="bottom: 0.9rem;" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_2.jpg"/>
            <input style="width: 59%;" type="number" name="" id="code" pattern="[0-9]*" value="" />
            <input type="button" class="huoqu" value="获取验证码">
            <img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_3.jpg"/>
        </li>
        <!-- <li>
            <p class="form_con">领取版本 <span style="color: #ff0000;">*</span></p>
            <div style="margin-top: 0.2rem;">
                <input type="radio" name="type" id="radio1" value="全国版文科" checked="checked" />
                <label class="radio-labels" for="radio1"><span class="value">全国版文科</span></label>
                <input type="radio" name="type" id="radio2" value="全国版理科" />
                <label class="radio-labels" for="radio2"><span class="value">全国版理科</span></label>
                <input type="radio" name="type" id="radio3" value="北京版" />
                <label class="radio-labels" for="radio3"><span class="value value_right">北京版</span></label>
            </div>
            <div style="margin-top: 0.2rem;">
                <input type="radio" name="type" id="radio4" value="江苏版" />
                <label class="radio-labels" for="radio4"><span class="value">江苏版</span></label>
                <input type="radio" name="type" id="radio5" value="浙江版" />
                <label class="radio-labels" for="radio5"><span class="value">浙江版</span></label>
                <input type="radio" name="type" id="radio6" value="新高考版" />
                <label class="radio-labels" for="radio6"><span class="value value_right">新高考版</span></label>
            </div>
        </li> -->
        <!-- <li>
            <p class="form_con subject">领取科目 <span style="color: #ff0000;">*</span></p>
            <input type="checkbox" name="subject" id="yuwen" value="语文" />
            <label class="checkbox_label" for="yuwen"><span class="value">语文</span></label>
            <input type="checkbox" name="subject" id="shuxue" value="数学" />
            <label class="checkbox_label" for="shuxue"><span class="value">数学</span></label>
        </li> -->
    </ul>

    <div class="dotm_btn">
        <input type="submit" value="提交" class="dotm_btn1">
    </div>

</div>

<script>
    var volume_id = '{$row->id}';

    $(function(){

        var arrarea = [];
        var province = "{$area.province??1}";
        var city = "{$area.city??2}";
        var area = "{$area.area??3}";
        var province_more = '';
        var city_more = '';
        var area_more = '';
        $.ajax({
            type: "post",
            url: "/api/ajax/area",
            dataType: "json",
            async: false,
            success: function(res){
                arrarea = res.data;
                console.log(arrarea);
            }
        });
        for (var i = 0; i < arrarea.length; i++) {
            if(province == arrarea[i]['id']){
                province_more = i;
                for (var s = 0; s < arrarea[i]['childs'].length; s++) {
                    if(city == arrarea[i]['childs'][s]['id']){
                        city_more = s;
                        for (var a = 0; a < arrarea[i]['childs'][s]['childs'].length; a++) {
                            if(area == arrarea[i]['childs'][s]['childs'][a]['id']){

                                area_more = a;
                            }
                        }
                    }
                }
            }
        }
        console.log(province_more);
        console.log(city_more);
        var mobileSelect4 = new MobileSelect({
            trigger: '#trigger4',
            title: '地区选择',
            wheels: [{data:arrarea}],
            position:[province_more,city_more,area_more],
            callback:function(indexArr, data){
                $('#sheng').val(data[0].id);
                $('#shi').val(data[1].id);
                $('#xian').val(data[2].id);
            }
        });

        //学校班级联动
        var mobileSelect5 = new MobileSelect({
            trigger: '#trigger5',
            title: '学校选择',
            wheels: [{data:[
                    {
                        id:'1',
                        value:'',
                        childs:[
                            {id:'A1',value:''},
                        ]
                    }
                ]}],
            transitionEnd:function(indexArr, data){

            },
            callback:function(indexArr, data){
                console.log(data);
                $('#school').val(data[0].id);
                if(data[0].id == -1){
                    $(".hide").show();
                }else{
                    $('#classname').val(data[1].value);
                    $(".hide").hide();
                }
            }
        });
        $.ajax({
            type: "get",
            url: "https://oa.fc62.com/api/ajax/ques_school/ids/"+volume_id,
            dataType: "json",
            success: function(res){
                var qita = {
                    id:"-1",
                    value:"其他学校",
                    childs:[]
                }
                res.data.push(qita);
                mobileSelect5.updateWheels(res.data);
            }
        });
        //点击获取验证码
        $('.huoqu').click(function() {
            var tel = $('#tel').val();
            if(!(/^1[3456789]\d{9}$/.test(tel))) {
                layer.open({
                    content: '请输入正确的手机号码',
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
                return false;
            }
            $.ajax({
                type: 'post',
                url:"/api/sms/send" ,
                data:{mobile:tel,event:'schoolques'},
                success: function(data){
                    console.log(data);
                    if(data.code != 1){
                        layer.open({
                            content:data.msg ,
                            skin: 'msg',
                            time: 2 //2秒后自动关闭
                        });
                        return false
                    }else{
                        var count = 120;
                        const countDown = setInterval(() => {
                            if (count === 0) {
                                $('.huoqu').val('重新发送').removeAttr('disabled');
                                $('.huoqu').css({
                                    background: '#f3494c',
                                    color: '#fff',
                                });
                                clearInterval(countDown);
                            } else {

                                $('.huoqu').css({
                                    background: '#eee',
                                    color: '#333',
                                });
                                $('.huoqu').val(count + '秒后可重新获取');
                                $('.huoqu').attr('disabled', true);
                            }
                            count--;
                        }, 1000);
                    }
                }
            });
        });
        //点击提交按钮
        $('.dotm_btn1').click(function(){
            var sheng = $('#sheng').val();
            var shi = $('#shi').val();
            var xian = $('#xian').val();
            var code = $('#code').val();
            var name = $('#name').val();//学生姓名
            var parent_name = $('#parent_name').val();
            var tel = $('#tel').val();
            var address = $('#address').val();
            var school = $('#school').val();//选择学校
            var totalschool = $('#totalschool').val();//全部学校
            var classname = $('#classname').val();//班级
            var qitaclassname = $('#qitaclassname').val();//班级
            //var type = $("input[name='type']:checked").val();//版本
            // var arr =[];
            // $('input[name="subject"]:checked').each(function(){
            // 	arr.push($(this).val());
            // });
            // var subject = arr.join();//学科
            if(name == ""||name == null){
                layer.open({
                    content: '请填写学生姓名',
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
                return false;
            }
            if(parent_name == ""||parent_name == null){
                layer.open({
                    content: '请填写家长姓名',
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
                return false;
            }

            if(school == ""||school == null){
                layer.open({
                    content: '请选择学校',
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
                return false;
            }else if(school == -1){
                if(totalschool == 0){
                    layer.open({
                        content: '请选择学校',
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    return false;
                }
                if(qitaclassname == ""||qitaclassname == null){
                    layer.open({
                        content: '请填写班级',
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    return false;
                }else{
                    classname = qitaclassname;
                }
            }
            if(sheng == ""||sheng == null){
                layer.open({
                    content: '请选择所在地区',
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
                return false;
            }
            if(address == ""||address == null){
                layer.open({
                    content: '请填写详细地址',
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
                return false;
            }
            if(!(/^1[3456789]\d{9}$/.test(tel))) {
                layer.open({
                    content: '请输入正确的手机号码',
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
                return false;
            }
            if(code == ""||code == null){
                layer.open({
                    content: '请填写验证码',
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
                return false;
            }
            // if(type == ""|| type == null){
            //     layer.open({
            //         content: '请选择领取版本',
            //         skin: 'msg',
            //         time: 2 //2秒后自动关闭
            //     });
            //     return false;
            // }

            var index = layer.open({type: 2});
            //验证验证码
            $.ajax({
                type: 'post',
                url:"/api/sms/check" ,
                data:{mobile:tel,captcha:code,event:'schoolques'},
                success: function(data){
                    if(data.code == 0){
                        layer.close(index);
                        layer.open({
                            content: data.msg,
                            skin: 'msg',
                            time: 2,
                        });
                        return false;
                    }else{
                        //添加禁止标签
                        $('.dotm_btn1').attr("disabled","disabled");
                        //提交表单
                        $.ajax({
                            type: 'post',
                            url:"/index/ques/school" ,
                            data:{shen:sheng,shi:shi,xian:xian,name:name,parent_name:parent_name,phone:tel,school:school,totalschool:totalschool,classname:classname,address:address,volume_id:volume_id},
                            success: function(data){
                                console.log(data);
                                if(data.code == 0){
                                    layer.close(index);
                                    $('.dotm_btn1').attr("disabled","");
                                    layer.open({
                                        content: data.msg,
                                        skin: 'msg',
                                        time: 2,
                                    });
                                    return false;
                                }else{
                                    console.log(data.data);

                                    layer.close(index);
                                    //var findlUrl = 'https://shoptest.fc62.com/activity/submit_success/32'
                                    window.location.href=data.data;
                                }

                            }
                        });
                    }

                }
            });
        });

    });
</script>
<!--  add表单结束  -->
{else}

<!-- edit表单开始   -->
{/if}
{/if}

</body>

</html>